<?php
/**
 * Created By virus_cms
 * Author: Virus
 * Date: 2020/3/2
 * Time: 20:31
 */

namespace app\admin\validate;


use think\Validate;

class RuleValidate extends Validate
{
    protected $rule = [
        'id'      => 'require|number|integer',
        'pid'     => 'require|number|integer',
        'name'    => 'require',
        'title'   => 'require',
        'type'    => 'require|number|integer',
        'is_menu' => 'require|number|integer',
        'status'  => 'require|number|integer',
    ];

    protected $message = [
        'pid.require'     => '父级权限不能为空',
        'pid.number'      => '父级pid必须为数字',
        'pid.integer'     => '父级pid必须为整型',
        'name.require'    => '权限规则不能为空',
        'title.require'   => '权限标题不能为空',
        'type.require'    => '权限类型不能为空',
        'type.number'     => '权限类型必须是数字',
        'type.integer'    => '权限类型必须是整型',
        'is_menu.require' => '是否是菜单不能不选',
        'is_menu.number'  => '是否是菜单必须是数字',
        'is_menu.integer' => '是否是菜单必须是整型',
        'status.require'  => '状态不能不选',
        'status.number'   => '状态值为数字',
        'status.integer'  => '状态值必须为整型',
        'id.require'      => '权限id必须存在',
        'id.number'       => '权限id必须是数字',
        'id.integer'      => '权限id必须是整型',
    ];

    protected $scene = [
        'add'  => ['pid', 'name', 'title', 'type', 'is_menu', 'status'],
        'edit' => ['id', 'pid', 'name', 'title', 'type', 'is_menu', 'status'],
    ];
}